<?php
require_once("includes/pagetop.php");
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<title>AllyFolio | Company Page List </title>
<link href="css/style.css" rel="stylesheet" type="text/css" media="all"  />

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js">
</script>
<script>
//<![CDATA[
$(document).ready(function(){
  $(".drop_btn").click(function(){
    $(".showbox").toggle();
  });
});

//]]>
</script>
</head>

<body>

	<div id="main_wrapper">
    <?php
    $pageheading="Company Page List";
    require_once("includes/header.php");
    
    $userID=$_SESSION["Allyfolio_User_ID"];
    
    //Perform delete
    if(isset($_REQUEST["dpage"]) && $_REQUEST["dpage"]!="")
    {
		$qryPageDetail="select * from af_company_page where Page_Slug=:Page_Slug and User_ID=:User_ID and Status=0";
		$arrPageDetail=$pdodbobj->fetch_array($pdodbobj->query($qryPageDetail,array(":Page_Slug"=>$_REQUEST["dpage"],":User_ID"=>$_SESSION["Allyfolio_User_ID"])));
		if(is_array($arrPageDetail) && count($arrPageDetail)>0)
		{
			//$qryDelete="delete from af_company_page where Page_Slug=:Page_Slug and User_ID=:User_ID";
			$qryDelete="update af_company_page set Status=2 where Page_Slug=:Page_Slug and User_ID=:User_ID";
			$pdodbobj->query($qryDelete,array(":Page_Slug"=>$_REQUEST["dpage"],":User_ID"=>$_SESSION["Allyfolio_User_ID"]));
			$msg_success="Company Page has been deleted successfully.";
		}
		else{
			$msg_error="Looks like there is some problem. Please try after some time.";
		}
	}
    
    
    $pageqry="select * from af_company_page where User_ID=:User_ID and Status=0";
    $pagelist=$pdodbobj->fetch_array($pdodbobj->query($pageqry,array(":User_ID"=>$userID)));
    
    if(count($pagelist)==0)
    {
        $_SESSION["msg_error"]="There is not company pages.";
        redirect("home.php");
    }
    ?>
    <!--=================Body Contain Start=======================-->
    <div class="wrapper">
    	<div class="header">
        	        	<div class="contain-wrap">
							<div class="c2">
								<?php if(count($pagelist)>0) echo "Company Page List"; ?>
							</div>
                            <form name="careerform" method="post">
                                <ol style="list-style-type: decimal;width: 436px;margin: 30px auto;">
                                    <?php
                                    for($i=0;$i<count($pagelist);$i++)
                                    {
                                    ?>
                                    <li>
                                        <a style="font-style:inherit;color: inherit;" href="page.php?page=<?php echo $pagelist[$i]['Page_Slug']; ?>"><?php echo $pagelist[$i]['Comp_Page_Name']; ?></a> 
                                    </li>
                                    <?php
                                    }
                                    ?>
                                </ol>
                            </form>
							<div>
                            
                            </div>
							
						</div>
</div>
                </div>
            
            
		</div>
    </div>
    
    <div class="clearfix"></div>
    <!--=================Body Contain end=======================-->
    </div>
<?php
    require_once("includes/footer.php");
?>
<script>
<?php
if(isset($msg_success) && $msg_success!="")
{
    ?>
    alertify.alert("<?php echo $msg_success; ?>");
    <?php
}

if(isset($msg_error) && $msg_error!="")
{
    ?>
    alertify.alert("<?php echo $msg_error; ?>");
    <?php
}
?>
</script>